Hi all
string linkNextValue(string &s)
{
string result = ""
Regexp hasField = regexp "(^|[ ,;\t\n]*)([^,;\t\n]*[^ ,;\t\n])($|[ ,;\t\n]+)"
while ((null result) and (! null s))
{
hasField s
result = s[match 2]
s = s[end(0)+1:]
}
delete hasField
return result
}
string strAppList= "V2.3.1P"
string strApplicability
while (!null strAppList)
{
strApplicability = linkNextValue(strAppList)
}
print strApplicability
SystemAdmin - Tue Aug 23 04:13:38 EDT 2011 |
Re: Strange behaviour with regexp and DOORS 9.2
Its advertised that they changed the internal Regular expression engine as part of the "blue washing" and that regular expression may not work identically and that you should test each one. Not sure what "regexp2" does but they say use that from now one.
const string cl_re_strAnyChar = "[" charOf(1)"-" charOf(255)"]" // Any ascii character except null
string ReString = "^" // start of string -
"([ ,;\t\n]*)" // zero or more delimiters -
"([^,;\t\n]*[^ ,;\t\n])" // one or more non-delimiters
//print "ReString = <<<<<" ReString ">>>>>\n"
Regexp hasField = regexp (ReString)
string linkNextValue(string &s)
{
string result
if (hasField s)
{
result = s[match 2]
s = s[end(0)+1:]
}
else
{ result = ""
s = ""
}
return result
}
void RunTest(string InString)
{
string strApplicability
string Remainder = InString
int FieldNum = 0
print "=============" InString "=============\n"
while (!null Remainder)
{
strApplicability = linkNextValue(Remainder)
print "\t" (FieldNum++) "\t^" strApplicability "^\n"
}
}
RunTest("A;B;C ;D")
RunTest("V2.3.1P; jdjdk")
RunTest("V2.3.1P ;dd d.,dd")
RunTest("V2.3.1P;;;")
delete hasField
// ============= It produces this in v92:
=============A;B;C ;D=============
0 ~A~
1 ~B~
2 ~C~
3 ~D~
=============V2.3.1P; jdjdk=============
0 ~V2.3.1P~
1 ~jdjdk~
=============V2.3.1P ;dd d.,dd=============
0 ~V2.3.1P~
1 ~dd d.~
2 ~dd~
=============V2.3.1P;;;=============
0 ~V2.3.1P~
1 ~~
Go here and 'find' "greedy". I thought I was going to need that but I didn't.
|
Re: Strange behaviour with regexp and DOORS 9.2 llandale - Tue Aug 23 12:09:25 EDT 2011
Its advertised that they changed the internal Regular expression engine as part of the "blue washing" and that regular expression may not work identically and that you should test each one. Not sure what "regexp2" does but they say use that from now one.
const string cl_re_strAnyChar = "[" charOf(1)"-" charOf(255)"]" // Any ascii character except null
string ReString = "^" // start of string -
"([ ,;\t\n]*)" // zero or more delimiters -
"([^,;\t\n]*[^ ,;\t\n])" // one or more non-delimiters
//print "ReString = <<<<<" ReString ">>>>>\n"
Regexp hasField = regexp (ReString)
string linkNextValue(string &s)
{
string result
if (hasField s)
{
result = s[match 2]
s = s[end(0)+1:]
}
else
{ result = ""
s = ""
}
return result
}
void RunTest(string InString)
{
string strApplicability
string Remainder = InString
int FieldNum = 0
print "=============" InString "=============\n"
while (!null Remainder)
{
strApplicability = linkNextValue(Remainder)
print "\t" (FieldNum++) "\t^" strApplicability "^\n"
}
}
RunTest("A;B;C ;D")
RunTest("V2.3.1P; jdjdk")
RunTest("V2.3.1P ;dd d.,dd")
RunTest("V2.3.1P;;;")
delete hasField
// ============= It produces this in v92:
=============A;B;C ;D=============
0 ~A~
1 ~B~
2 ~C~
3 ~D~
=============V2.3.1P; jdjdk=============
0 ~V2.3.1P~
1 ~jdjdk~
=============V2.3.1P ;dd d.,dd=============
0 ~V2.3.1P~
1 ~dd d.~
2 ~dd~
=============V2.3.1P;;;=============
0 ~V2.3.1P~
1 ~~
Go here and 'find' "greedy". I thought I was going to need that but I didn't.
My concern was mainly that my code doesn't return the same result when you execute it twice and that's what worries me !!! Even if I create new regexp, how can I be sure it will always work !!! We post a case to IBM. They replied with an incomprehensible explanation (In french and I'm French ;-)). So we asked them a more clear explanation Regards |
Re: Strange behaviour with regexp and DOORS 9.2
I am wondering why you return the original value as null using the following line of code. string linkNextValue(string &s) |